#include <iostream>
#include <cstring>
#include <cmath>

using namespace std;

int st[1000001] = {0};
int ret[1000001];

int main(){
	
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	cin >> n;
	int arr[n];
	for(int i =0; i < n; ++i){
		cin >> arr[i];
		++st[arr[i]];
	}
	
	memset(ret,-1,sizeof(ret));
	
	for(int i = 0; i < n; ++i){
		if(ret[arr[i]] != -1){
			cout << ret[arr[i]];
			if(i != n - 1) cout << endl;
			continue;
		}
		int ans = 0;
		for(int j = 1; j <= sqrt(arr[i]); ++j){
			if(arr[i] % j == 0){
				int t = arr[i] / j;
				ans += st[j];
				if(t != j) ans += st[t];
			}
		}
		--ans;
		ret[arr[i]] = ans;
		cout << ans;
		if(i != n - 1) cout << endl;
	}

	return 0;
}

